package cp8_pool;

import util.DataSourceTool;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class DataSourceTest {
    public static void main(String[] args) throws Exception {
        DataSource ds = DataSourceTool.createDruidSource();
        Connection connection = ds.getConnection();
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select count(*) as data_count from userinfo");
        if (resultSet.next()) {
            int count = resultSet.getInt(1);// 索引
            int count1 = resultSet.getInt("data_count");// 列名
            System.out.println("数据条数:" + count1 + "===" + count);
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}
